package com.maxatime.service.impl;

import com.maxatime.dao.GradeMapper;
import com.maxatime.exception.PhoenixException;
import com.maxatime.pojo.*;
import com.maxatime.service.GradeService;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author Mr.Zhao
 * @title: GradeServiceImpl
 * @projectName phoenix
 * @description: TODO
 * @date 2021/7/30 8:46
 */
@Service
public class GradeServiceImpl implements GradeService {
    @Autowired
    private GradeMapper gradeMapper;

    Logger log = LogManager.getLogger();

    @Override
    public List<Classroom> gradeFind(GradeVo vo) {
        return gradeMapper.gradeFind(vo);
    }

    @Override
    public Integer gradeDelete(int pkId) {
        return gradeMapper.gradeDelete(pkId);
    }




    @Override
    public Integer updateGrade(Grade grade) throws PhoenixException {
        try {
            return gradeMapper.updateByPrimaryKeySelective(grade);
        } catch (Exception e) {
            log.error("gradeMapper.updateGrade:::" + grade);
            log.error("gradeMapper.updateGrade:::" + e.getMessage());
            throw new PhoenixException("9999", "修改失败");

        }
    }

    @Override
    public Grade selectKey(Integer Id) {
        return gradeMapper.selectByPrimaryKey(Id);
    }

    @Override
    public List<EmployeeInfo> EmployeeInfoList() {
        return gradeMapper.EmployeeInfoList();
    }

    @Override
    public List<Classroom> classroomList() {
        return gradeMapper.classroomList();
    }

    @Override
    public EmployeeInfo selectKe(String employeeId) {
        return gradeMapper.selectKe(employeeId);
    }

    @Override
    public Classroom selectList(String classroomId) {
        return gradeMapper.selectList(classroomId);
    }

    @Override
    public Integer addGrade(Grade grade) throws PhoenixException {
        try {
            return gradeMapper.insertSelective(grade);
        } catch (Exception e) {
            log.error("gradeMapper.insertSelective:::" + grade);
            log.error("gradeMapper.insertSelective:::" + e.getMessage());
            throw new PhoenixException("9999", "添加失败");

        }
    }

    @Override
    public Integer addgrc(GradeClassroomRelation gcr) {
        return gradeMapper.addgrc(gcr);
    }

    @Override
    public Integer deleteListGrade(List<Integer> list) {
        return gradeMapper.deleteListGrade(list);
    }

    @Override
    public List<StudentMessage> viewstudentin(String gradeId) {
        return gradeMapper.viewstudentin(gradeId);
    }


}